<?php

use Welcomescreen\Agavi\Action;

class Frontend_GetActiveScreensAction extends Action\FrontendBaseAction {
	public function executeRead(AgaviWebRequestDataHolder $rd) {
		$visits = $this->getContext()->getModel('VisitManager')->getVisits();
		$ids = array();
		$defaultIds = array();
		foreach($visits as $visit) {
			if($visit->isActive() && !$visit->isDefault()) {
				$ids[] = $visit->getId();
			} elseif($visit->isDefault()) {
				$defaultIds[] = $visit->getId();
			}
		}
		if(count($ids) == 0) {
			$ids = $defaultIds;
		}
		$this->setAttribute('ids', $ids);
		
		return 'Success';
	}

}

?>